package com.md.api.entity;

import lombok.AccessLevel;
import lombok.Data;
import lombok.experimental.FieldDefaults;

@Data
@FieldDefaults(level=AccessLevel.PRIVATE)
public class HttpResult {

	public final static HttpResult OK = new HttpResult(200, "操作成功");

	public final static HttpResult ACCEPTED = new HttpResult(202, "暂无响应");

	public final static HttpResult FAILED = new HttpResult(400,"操作失敗");

	public final static HttpResult NO_LOGIN = new HttpResult(401, "您未登錄或登錄超時，請重新登錄");

	public final static HttpResult NO_AUTH = new HttpResult(403, "操作失敗，權限校驗未通過，請求被拒絕");

	public final static HttpResult PARAM_ERROR = new HttpResult(405, "參數列表校驗未通過，請求被中斷");


	public final static HttpResult FALLBACK = new HttpResult(500, "服务器发生异常，请稍后重试");

	public final static HttpResult OTHER_LOGIN = new HttpResult(501, "您的账号已在其他地方登录，若非本人操作，请及时修改密码！");

	public final static HttpResult REQUEST_NOT_SUPPORTED = new HttpResult(501, "访问过于频繁!");

	public final static HttpResult SYSTEM_ERROR = new HttpResult(503, "系统繁忙,请稍后再试");

	public final static HttpResult METHOD_NOT_SUPPORTED = new HttpResult(505, "HTTP请求方法错误");

	public final static HttpResult PROMPT = new HttpResult(10001, "提示信息");

	public final static HttpResult SECRET_VISIT = new HttpResult(10002, "密碼不能爲空");


	Integer code;
	
	String msg;
	
	Object data;

	public HttpResult() {
		super();
		this.code = 200;
	}

	public HttpResult(Object data) {
		super();
		this.code = 200;
		this.data = data;
	}

	public HttpResult(Integer code, String msg) {
		super();
		this.code = code;
		this.msg = msg;
	}

	public HttpResult(Integer code, Object data) {
		super();
		this.code = code;
		this.data = data;
	}

	public HttpResult(Integer code, String msg, Object data) {
		super();
		this.code = code;
		this.msg = msg;
		this.data = data;
	}
	

	public static HttpResult fail(String msg) {
		return new HttpResult(505, msg);
	}

	public static HttpResult prompt(String msg) {
		return new HttpResult(10001, msg);
	}
}
